// pages/listDetail/listDetail.js
const app = getApp()
Page({
  
  data: {
    listArr:{},
    showModal:false,
    runnername:'',
    runnerphone:'',
    userId:''
  },

  onLoad: function (options) {
    console.log(options);
    this.setData({
      userId: app.data.userInfo.userid
    })
    wx.request({  
      url: 'https://www.woodymidnight.cn/BCUHelper/api/list/selectbylistid',  
      method: 'POST',
      data:{
        listId:options.listId
      } ,                                     
      header: { 'content-type': 'application/x-www-form-urlencoded' }, 
      success:res => {   
        console.log(res);
        this.setData({
          listArr: res.data.data
        })
      }
    })
  },

  makecall: function(t) {
    console.log(t.currentTarget.dataset.phone), 
    wx.makePhoneCall({
        phoneNumber: this.data.listArr.userphone
    });
  },

  handleQd:function(res){
    this.setData({       
      showModal: true,
    })
  },

   
  onCancel: function () {
    this.setData({
      showModal: false
    });
  },

  postInfo(e){
    if(this.data.runnername === '' || this.data.runnerphone === ''){
      wx.showToast({
        title: '请完善信息',
        icon: 'error',
        duration: 2000
      })
    }else{
      wx.request({
        url: 'https://www.woodymidnight.cn/BCUHelper/api/list/receivelist',
        method:'POST',
        header: { 'content-type': 'application/x-www-form-urlencoded' }, 
        data:{
          listid:this.data.listArr.listid,
          runnerid:this.data.userId,
          runnername:this.data.runnername,
          runnerphone:this.data.runnerphone,
          runnerjscode:''
        },
        success:(res)=>{
          console.log(res.data)
          wx.navigateBack({
            delta: 1,
          })
        },
      })
    }
  },

  inputChangeName:function(e){
    console.log(e.detail.value);
    this.setData({
      runnername : e.detail.value
    })
  },

  inputChangePhone:function(e){
    console.log(e);
    this.setData({
      runnerphone : e.detail.value
    })
  },

})